<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Role extends Base
{
    /**
     * 角色管理权限
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function nodes()
    {
        //第一个参数代表要关联的模型
        //第二个参数是中间表
        //第三个是本模型在中间表的外键
        //第四个是关联模型在中间表的外键
        return $this->belongsToMany(Node::class,'role_nodes','role_id','node_id');
    }
}
